--- 战策八·绝处逢生
local policy8 = fk.CreateSkill {
    name = "getlive_indeath",
    tags = { Skill.Compulsory },
    dynamic_name = function (self, player, lang)
      return player == Self and self.name or "unknownpolicy"
    end,
    dynamic_desc = function (self, player, lang)
      return player == Self and self.name or "unknownpolicy"
    end,
}

local HG = require "packages/new_heg_diy_my/util"

Fk:loadTranslationTable{
    ["@[getlive_indeath_mark]"] = "绝处逢生",
    ["getlive_indeath_ask"] = "战策-绝处逢生：你可以弃置所有手牌，回复1点体力",
}

policy8:addEffect(fk.EnterDying, {
    anim_type = "defensive",
    can_trigger = function(self, event, target, player, data)
        local mark_name = "@[private]" .. policy8.name .. "_mark"
        return player:getMark(mark_name) ~= 0 and player == target and not player:isKongcheng()
    end,
    on_cost = function(self, event, target, player, data)
        return player.room:askToSkillInvoke(player, { skill_name = "unknownpolicy", prompt = "getlive_indeath_ask" })
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local mark_name = "@[private]" .. policy8.name .. "_mark"
        player:throwAllCards("h")
        room:recover {
            who = player,
            num = 1,
            recoverBy = player,
            skillName = policy8.name,
        }
        room:setPlayerMark(player, mark_name, 0)
        room:handleAddLoseSkills(player, "-getlive_indeath", nil, false)
        room.logic:trigger(HG.HegLosePolicy, player, { player, policy8.name })
    end,
})

return policy8
